﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package Modules.realtime {
    import com.adobe.serialization.json.*;

    public class RealtimeMethod {

        private var m_functionName:String;
        private var m_arguments:Array;
        public var zid:String;

        public function RealtimeMethod(_arg1:String=null, ... _args){
            if (_arg1 == null){
                return;
            };
            this.m_functionName = _arg1;
            this.m_arguments = _args;
        }
        public function createFromString(_arg1:String):void{
            var obj:* = null;
            var json:* = _arg1;
            var arguments:* = arguments;
            try {
                obj = JSON.decode(json);
                this.m_functionName = obj.functionName;
                this.m_arguments = obj.arguments;
            } catch(error:Error) {
                m_functionName = null;
            };
        }
        public function execute():void{
            var _local1:Function;
            if (this.m_functionName){
                if (!RealtimeMethods[this.m_functionName]){
                    return;
                };
                _local1 = (RealtimeMethods[this.m_functionName] as Function);
                if (this.zid){
                    this.m_arguments.unshift(this.zid);
                    _local1.apply(null, this.m_arguments);
                };
            };
        }
        public function get jsonString():String{
            var _local2:Object = new Object();
            _local2.functionName = this.m_functionName;
            _local2.arguments = this.m_arguments;
            return (JSON.encode(_local2));
        }

    }
}//package Modules.realtime 
